#include <linux/cpu.h>
#include <linux/percpu.h>
#include <linux/minmax.h>

#include "inc/cpu_state.h"

/**
 * notify_cpu_starting(cpu) - Invoke the callbacks on the starting CPU
 * @cpu: cpu that just started
 *
 * It must be called by the arch code on the new cpu, before the new cpu
 * enables interrupts and before the "boot" cpu returns from __cpu_up().
 */
void notify_cpu_starting(unsigned int cpu)
{
	struct cpuhp_cpu_state *st = per_cpuhp_cpu_state(cpu);
	enum cpuhp_state target = min(st->target, CPUHP_AP_ONLINE);

	/*
	 * STARTING must not fail!
	 */
	cpuhp_invoke_callback_range_nofail(true, cpu, st, target);
}
